/*******************************************************************************
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * Copyright (c) 2011 Michael Chan.
 ******************************************************************************/
package com.google.code.solrdimension.core.dimensions;

import com.google.code.solrdimension.core.DimensionResponse;

/**
 * DimensionValue holds the info required for displaying facet values, and
 * parameter necessary for generating an URL for selecting the Facet.
 * 
 * Note that the facetPrefixQuery has two purpose.
 * <ul>
 * <li>When this is for rendering AVAILABLE refinements, i.e
 * {@link DimensionResponse#getDimensions()}, the facetPrefixQuery is populated</li>
 * <li>When this is for rendering SELECTED refinements, i.e
 * {@link DimensionResponse#getSelectedDimensions()}, if the selected
 * dimensionValue is a prefix, this will be populated and when the selected
 * dimensionValue is a filter with prefix, the prefix part will go into the facetPrefixQuery</li>
 * </ul>
 * 
 * @author mhc
 * 
 */
public class DimensionValue implements Comparable<DimensionValue> {

    private long count;

    private String filterQuery;

    private String facetPrefixQuery;

    private String displayName;

    /**
     * This is mainly for SELECTed facet only.
     */
    private String prefixDisplayName;

    public DimensionValue(String displayName, String filterQuery, String facetPrefixQuery, long count) {

        this.displayName = displayName;
        this.facetPrefixQuery = facetPrefixQuery;
        this.filterQuery = filterQuery;
        this.count = count;

    }
    
    public DimensionValue(String displayName, String filterQuery, String facetPrefixQuery, long count, String facetPrefixName) {
        
        this(displayName, filterQuery, facetPrefixQuery, count);
        this.prefixDisplayName = facetPrefixName;
        
    }
    
    public String getPrefixDisplayName() {
        return prefixDisplayName;
    }

    public void setPrefixDisplayName(String prefixDisplayName) {
        this.prefixDisplayName = prefixDisplayName;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public String getFilterQuery() {
        return filterQuery;
    }

    public void setFilterQuery(String filterQuery) {
        this.filterQuery = filterQuery;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public String getFacetPrefixQuery() {
        return facetPrefixQuery;
    }

    public void setFacetPrefixQuery(String facetPrefixQuery) {
        this.facetPrefixQuery = facetPrefixQuery;
    }

    // comparison is only for name

    public int compareTo(DimensionValue dimval) {

        return this.displayName.compareTo(dimval.getDisplayName());
    }

}
